package com.prs.crm.action.oa;

import java.util.List;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.courser.struts.BaseAction;
import org.courser.ui.PaginationSupport;
import org.hibernate.criterion.DetachedCriteria;

import com.prs.crm.domain.oa.FramesSet;
import com.prs.crm.domain.oa.ModuleMaintain;
import com.prs.crm.service.oa.FramesSetService;
import com.prs.crm.service.oa.ModuleMaintainService;

public class ModuleMaintainAction extends BaseAction{
	private static final long serialVersionUID = 1L;
	private ModuleMaintain moduleMaintain;
	private ModuleMaintainService moduleMaintainService;
	private PaginationSupport pagination;
	private String moduleState;
	
	private FramesSet framesSet;
	private FramesSetService framesSetService;
	
	private List<FramesSet> frames;
	
	private Integer[] ids;

	public Integer[] getIds() {
		return ids;
	}
	public void setIds(Integer[] ids) {
		this.ids = ids;
	}
	public ModuleMaintain getModuleMaintain() {
		return moduleMaintain;
	}
	public void setModuleMaintain(ModuleMaintain moduleMaintain) {
		this.moduleMaintain = moduleMaintain;
	}
	public ModuleMaintainService getModuleMaintainService() {
		return moduleMaintainService;
	}
	public void setModuleMaintainService(ModuleMaintainService moduleMaintainService) {
		this.moduleMaintainService = moduleMaintainService;
	}
	public PaginationSupport getPagination() {
		return pagination;
	}
	public void setPagination(PaginationSupport pagination) {
		this.pagination = pagination;
	}
	public String getModuleState() {
		return moduleState;
	}
	public void setModuleState(String moduleState) {
		this.moduleState = moduleState;
	}
	public FramesSet getFramesSet() {
		return framesSet;
	}
	public void setFramesSet(FramesSet framesSet) {
		this.framesSet = framesSet;
	}
	public FramesSetService getFramesSetService() {
		return framesSetService;
	}
	public void setFramesSetService(FramesSetService framesSetService) {
		this.framesSetService = framesSetService;
	}
	public List<FramesSet> getFrames() {
		return frames;
	}
	public void setFrames(List<FramesSet> frames) {
		this.frames = frames;
	}
	@Action("listModuleMaintain")
	public String listModuleMaintain(){
		DetachedCriteria criteria=this.getPaginationHelper().createQuery(ModuleMaintain.class);
		pagination=this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getModuleMaintainService().listByPage(criteria, pagination));
		return SUCCESS;
	}
	@Action("listModuleMaintains")
	public String listModuleMaintains(){
		DetachedCriteria criteria=this.getPaginationHelper().createQuery(ModuleMaintain.class);
		pagination=this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getModuleMaintainService().listByPage(criteria, pagination));
		return  SUCCESS;
	}
	@Action("editFlowSet")
	public String editFlowSet(){
		return SUCCESS;
	}
	@Action(value = "saveFlowSet", results = {
			@Result(name = "success", type = "redirect", location = "listModuleMaintains"),
			@Result(name = "error", type = "chain", location = "editFlowSet"),
		 })
	public String saveFlowSet(){
		this.moduleMaintainService.save(moduleMaintain);
		return SUCCESS;
	}
	@Action("editModuleMaintain")
	public String editModuleMaintain(){
		return SUCCESS;
	}
	@Action(value = "saveModuleMaintain", results = {
			@Result(name = "success", type = "redirect", location = "listModuleMaintain"),
			@Result(name = "error", type = "chain", location = "editModuleMaintain"),
		 })
	public String saveModuleMaintain(){
		moduleMaintain.setModuleState("启用");
		this.getModuleMaintainService().save(moduleMaintain);
		return SUCCESS;
	}
}
